<?php
/**
 * Created by jack.
 * User: liangbo
 * Date: 2017/9/23
 * Time: 下午11:39
 * warning:此代码属于内部版权，未经许可，不得转让
 */

namespace backend\services;

use yii;
class ToolService
{

    /**
    *@功能:邮件发送
    *@author 梁波
    *@日期时间:2017/9/23
    */
    public function sendMessage($mail)
    {
        $code=randYzm();
        $mailClient= Yii::$app->mailer->compose();
        $mailClient->setTo($mail);
        $mailClient->setSubject("微信机器人云平台邮箱验证邮件");
        $mailClient->setHtmlBody("<div>感谢注册,你的验证码是<font color='red'>"+$code+"</font></div>");    //发布可以带html标签的文本
        if($mailClient->send())
        {
            yii::$app->cache->set($mail,$code);
            return $code;

        } else
           return 0;
    }

    public function on($res,\Closure $closure)
    {
        return call_user_func($closure,$res);
    }

}